//
//  UrbanLawEnTableViewCell.m
//  UrbanManagement
//
//  Created by Can on 18/4/11.
//  Copyright © 2018年 hwd. All rights reserved.
//

#import "UrbanLawEnTableViewCell.h"

@implementation UrbanLawEnTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        //添加控件
        [self addSubviews];
    }
    return self;
}

- (void)addSubviews
{
    //右侧单选按钮
    _choseBtn = [TomamaUI createButton:0 Frame:CGRectMake(15*screenW_6, 0, 20*screenW_6, 20*screenW_6) targ:self sel:@selector(chose) titleColor:nil font:nil title:nil image:@"unselected" backGroundImage:nil];
    _choseBtn.backgroundColor = [UIColor whiteColor];
    _choseBtn.layer.cornerRadius = 10*screenW_6;
    _choseBtn.layer.masksToBounds = YES;
    [self.contentView addSubview:_choseBtn];
    _choseBtn.center = CGPointMake(_choseBtn.center.x, (227/2*screenW_6 + 10*screenW_6)/2);
    
    //背景图片
    UIImageView *imageView = [TomamaUI createImageView:CGRectMake(CGRectGetMaxX(_choseBtn.frame) + 15*screenW_6, 5*screenW_6, SCREENW - CGRectGetMaxX(_choseBtn.frame) - 30*screenW_6, 227/2*screenW_6) backGroundImageV:@"piao-1"];
    [self.contentView addSubview:imageView];
    
    //价格
    UILabel *moneyLable = [TomamaUI createLabel:CGRectMake(0, 0, 100*screenW_6, 24*screenW_6) textAligment:1 font:[UIFont systemFontOfSize:24*screenW_6] textColor:[UIColor whiteColor] text:@"¥ 100"];
    [imageView addSubview:moneyLable];
    moneyLable.center = CGPointMake(moneyLable.center.x, (227/2*screenW_6 + 10*screenW_6)/2);
    
    //行为
    UILabel *behavior = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(moneyLable.frame) + 15*screenW_6, 0, imageView.frame.size.width - moneyLable.frame.size.width - 30*screenW_6, 13*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:13*screenW_6] textColor:Color(153, 153, 153) text:@"行为:机动车违反交通规定，临时停车且驾驶人不在现场，妨碍其它车辆行驶"];
    [imageView addSubview:behavior];
    behavior.frame = CGRectMake(CGRectGetMaxX(moneyLable.frame) + 15*screenW_6, 0, imageView.frame.size.width - moneyLable.frame.size.width - 30*screenW_6, [self lableHeight:behavior width:imageView.frame.size.width - moneyLable.frame.size.width - 30*screenW_6]);
    behavior.center = CGPointMake(behavior.center.x, (227/2*screenW_6 + 10*screenW_6)/2);
    
}

//lable高度
- (CGFloat)lableHeight:(UILabel *)lable width:(CGFloat)width{
    lable.numberOfLines = 0;//根据最大行数需求来设置
    lable.lineBreakMode = NSLineBreakByTruncatingTail;
    CGSize maximumLabelSize = CGSizeMake(width, 9999);//labelsize的最大值
    //关键语句
    CGSize expectSize = [lable sizeThatFits:maximumLabelSize];
    return expectSize.height;
}

- (void)chose
{
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
